/*
 * Galgje.java
 *
 * Created on 8 april 2008, 11:05
 */

package client.gui;

import client.communication.ClientCommunication;
import client.controllers.GalgjeController;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import org.apache.log4j.Logger;

/**
 *
 * @author  
 */
public class Galgje extends javax.swing.JPanel {
    private Logger logger = Logger.getLogger(Galgje.class);
    private JFrame parent;
    private String woord;
    private JLabel[] gevondenLetters;
    private int tijd;
    //private Timerclass timer;
    
    /** Creates new form Galgje */
    
    public Galgje(JFrame parent) {
        initComponents();
        this.parent = parent;
        GalgjeController.getInstance().setGalgjeclient(this);
        GalgjeController.getInstance().setTp(tekenPaneel1);
        GalgjeController.getInstance().reset();
        //tijd = 0;
        //timer = new Timerclass();
    }
    
    public void maakWoordPaneel(){
        pnlWoord.removeAll();
        woord = GalgjeController.getInstance().getGevondenWoord();
        pnlWoord.setLayout(new BorderLayout());
        JPanel pnl = new JPanel();
        gevondenLetters = new JLabel[woord.length()];
        for(int i = 0; i < woord.length(); i++){
            gevondenLetters[i] = new JLabel(""+woord.charAt(i),JLabel.CENTER);
            //gevondenLetters[i].setHorizontalTextPosition(JLabel.CENTER);
            gevondenLetters[i].setVerticalTextPosition(JLabel.CENTER);
            //gevondenLetters[i].setText("<html><center>"+woord.charAt(i)+"</center></html>");
            gevondenLetters[i].setMinimumSize(new Dimension(30,30));
            gevondenLetters[i].setPreferredSize(new Dimension(30,30));   
            
            gevondenLetters[i].setBorder(BorderFactory.createLineBorder(Color.black));
            pnl.add(gevondenLetters[i]);
        

        }
        pnlWoord.add(pnl,BorderLayout.CENTER);
        pnlWoord.revalidate();
    }
    
    public static void main(String args[]){
        JFrame venster = new JFrame("Galgje");
        venster.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        venster.add(new Galgje(venster));
        venster.setPreferredSize(new Dimension(800,800));
        venster.pack();
        venster.setVisible(true);
    }
 
//    private class Timerclass implements ActionListener{
//        private Timer t;
//        
//        Timerclass(){
//            t = new Timer(1000,this);
//            t.start();
//        }
//        
//        
//        public void actionPerformed(ActionEvent e) {
//            if (e.getSource() == getT()) {
//                tijd++;
//                lblWoord.setText((tijd/60>=10)?Integer.toString(tijd/60):"0"+(Integer.toString(tijd/60))+":"+((tijd-tijd/60)>=10?Integer.toString(tijd-tijd/60):"0"+Integer.toString(tijd-tijd/60)));
//            }
//        }
//
//        public Timer getT() {
//            return t;
//        }
//        
//    }
    
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pInfo = new javax.swing.JPanel();
        lblhulp = new javax.swing.JLabel();
        lblFouteLetters = new javax.swing.JLabel();
        pToetsenbord = new javax.swing.JPanel();
        btnA = new javax.swing.JButton();
        btnZ = new javax.swing.JButton();
        btnE = new javax.swing.JButton();
        btnR = new javax.swing.JButton();
        btnY = new javax.swing.JButton();
        btnT = new javax.swing.JButton();
        btnU = new javax.swing.JButton();
        btnI = new javax.swing.JButton();
        btnO = new javax.swing.JButton();
        btnP = new javax.swing.JButton();
        btnM = new javax.swing.JButton();
        btnL = new javax.swing.JButton();
        btnK = new javax.swing.JButton();
        btnJ = new javax.swing.JButton();
        btnH = new javax.swing.JButton();
        btnG = new javax.swing.JButton();
        btnF = new javax.swing.JButton();
        btnD = new javax.swing.JButton();
        btnS = new javax.swing.JButton();
        btnQ = new javax.swing.JButton();
        btnN = new javax.swing.JButton();
        btnB = new javax.swing.JButton();
        btnV = new javax.swing.JButton();
        btnC = new javax.swing.JButton();
        btnX = new javax.swing.JButton();
        btnW = new javax.swing.JButton();
        pnlWoord = new javax.swing.JPanel();
        tekenPaneel1 = new client.gui.controls.TekenPaneel();

        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                keyPress(evt);
            }
        });

        pInfo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        lblhulp.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblhulp.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        lblFouteLetters.setText("Foute letters");

        javax.swing.GroupLayout pInfoLayout = new javax.swing.GroupLayout(pInfo);
        pInfo.setLayout(pInfoLayout);
        pInfoLayout.setHorizontalGroup(
            pInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pInfoLayout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(pInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(lblFouteLetters, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblhulp, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE))
                .addContainerGap(25, Short.MAX_VALUE))
        );
        pInfoLayout.setVerticalGroup(
            pInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pInfoLayout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addComponent(lblFouteLetters)
                .addGap(18, 18, 18)
                .addComponent(lblhulp, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(306, Short.MAX_VALUE))
        );

        pToetsenbord.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        btnA.setText("a");
        btnA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnZ.setText("z");
        btnZ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnE.setText("e");
        btnE.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnR.setText("r");
        btnR.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnY.setText("y");
        btnY.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnT.setText("t");
        btnT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnU.setText("u");
        btnU.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnI.setText("i");
        btnI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnO.setText("o");
        btnO.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnP.setText("p");
        btnP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnM.setText("m");
        btnM.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnL.setText("l");
        btnL.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnK.setText("k");
        btnK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnJ.setText("j");
        btnJ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnH.setText("h");
        btnH.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnG.setText("g");
        btnG.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnF.setText("f");
        btnF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnD.setText("d");
        btnD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnS.setText("s");
        btnS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnQ.setText("q");
        btnQ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnN.setText("n");
        btnN.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnB.setText("b");
        btnB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnV.setText("v");
        btnV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnC.setText("c");
        btnC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnX.setText("x");
        btnX.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        btnW.setText("w");
        btnW.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPressed(evt);
            }
        });

        javax.swing.GroupLayout pToetsenbordLayout = new javax.swing.GroupLayout(pToetsenbord);
        pToetsenbord.setLayout(pToetsenbordLayout);
        pToetsenbordLayout.setHorizontalGroup(
            pToetsenbordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pToetsenbordLayout.createSequentialGroup()
                .addGap(128, 128, 128)
                .addComponent(btnQ)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnS)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnD)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnF)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnG)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnH)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnJ)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnK)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnL)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnM)
                .addContainerGap(108, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pToetsenbordLayout.createSequentialGroup()
                .addContainerGap(30, Short.MAX_VALUE)
                .addComponent(btnA)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnZ)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnR)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnT)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnY)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnU)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnI)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnO)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnP)
                .addGap(204, 204, 204))
            .addGroup(pToetsenbordLayout.createSequentialGroup()
                .addGap(146, 146, 146)
                .addComponent(btnW)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnX)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnC)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnV)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnB)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnN)
                .addContainerGap(266, Short.MAX_VALUE))
        );
        pToetsenbordLayout.setVerticalGroup(
            pToetsenbordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pToetsenbordLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pToetsenbordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnI, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnO, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnP, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnR, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnY, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnU, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnT, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnE, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnZ, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnA, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pToetsenbordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnQ, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnS, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnF, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnD, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnG, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnH, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnJ, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnK, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnL, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnM, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pToetsenbordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnW, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnX, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnV, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnC, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnB, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnN, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlWoord.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        pnlWoord.setMinimumSize(new java.awt.Dimension(40, 40));
        pnlWoord.setLayout(new java.awt.BorderLayout());

        tekenPaneel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        javax.swing.GroupLayout tekenPaneel1Layout = new javax.swing.GroupLayout(tekenPaneel1);
        tekenPaneel1.setLayout(tekenPaneel1Layout);
        tekenPaneel1Layout.setHorizontalGroup(
            tekenPaneel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 490, Short.MAX_VALUE)
        );
        tekenPaneel1Layout.setVerticalGroup(
            tekenPaneel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 361, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tekenPaneel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(pnlWoord, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 492, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pInfo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(pToetsenbord, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pInfo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(tekenPaneel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pnlWoord, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pToetsenbord, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void keyPress(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_keyPress
        // TODO add your handling code here:
        char key = evt.getKeyChar();
        GalgjeController.getInstance().testLetter(key);
        if(GalgjeController.getInstance().isVerloren()){
            JOptionPane.showMessageDialog(this, "U hebt verloren.");
            this.setVisible(false);
        }else if(GalgjeController.getInstance().isGewonnen()){
            JOptionPane.showMessageDialog(this, "U hebt verloren\nUw score wordt naar de server gestuurd.");
            this.setVisible(false);
        }
//        else{
//            lblWoord.setText(GalgjeController.getInstance().getGevondenWoord());
//        }
    }//GEN-LAST:event_keyPress

    private void btnPressed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPressed
        // TODO add your handling code here:
        String key = evt.getActionCommand();
        GalgjeController.getInstance().testLetter(key.charAt(0));
        lblhulp.setText(GalgjeController.getInstance().fouteLettersToString());
        woord = GalgjeController.getInstance().getGevondenWoord();
        for(int i = 0; i < woord.length(); i++){
            gevondenLetters[i].setText("<html><center>"+woord.charAt(i)+"</center></html>");
        }
        if(GalgjeController.getInstance().isVerloren()){
            JOptionPane.showMessageDialog(this, "U hebt verloren.\nHet te zoeken woord was "+GalgjeController.getInstance().getWoord());
            parent.setVisible(false);
            ClientCommunication.getInstance().verlaagGalgjeScore(ClientCommunication.getInstance().getChatroom().getGebruiker().getScoreId());
        }else if(GalgjeController.getInstance().isGewonnen()){
            JOptionPane.showMessageDialog(this, "U hebt gewonnen\nHet gezochte woord was inderdaad "+GalgjeController.getInstance().getWoord());
            parent.setVisible(false);
            ClientCommunication.getInstance().verhoogGalgjeScore(ClientCommunication.getInstance().getChatroom().getGebruiker().getScoreId());
        }
    }//GEN-LAST:event_btnPressed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnA;
    private javax.swing.JButton btnB;
    private javax.swing.JButton btnC;
    private javax.swing.JButton btnD;
    private javax.swing.JButton btnE;
    private javax.swing.JButton btnF;
    private javax.swing.JButton btnG;
    private javax.swing.JButton btnH;
    private javax.swing.JButton btnI;
    private javax.swing.JButton btnJ;
    private javax.swing.JButton btnK;
    private javax.swing.JButton btnL;
    private javax.swing.JButton btnM;
    private javax.swing.JButton btnN;
    private javax.swing.JButton btnO;
    private javax.swing.JButton btnP;
    private javax.swing.JButton btnQ;
    private javax.swing.JButton btnR;
    private javax.swing.JButton btnS;
    private javax.swing.JButton btnT;
    private javax.swing.JButton btnU;
    private javax.swing.JButton btnV;
    private javax.swing.JButton btnW;
    private javax.swing.JButton btnX;
    private javax.swing.JButton btnY;
    private javax.swing.JButton btnZ;
    private javax.swing.JLabel lblFouteLetters;
    private javax.swing.JLabel lblhulp;
    private javax.swing.JPanel pInfo;
    private javax.swing.JPanel pToetsenbord;
    private javax.swing.JPanel pnlWoord;
    private client.gui.controls.TekenPaneel tekenPaneel1;
    // End of variables declaration//GEN-END:variables
    
}
